package com.dede.state.component;

import com.dede.state.StateLayout;

/**
 * loading...
 *
 * @author hsh
 *         2018/1/23 10:15.
 */
public abstract class LoadingComponent extends StateComponent {

    private boolean cancelable = true;
    private StateLayout stateLayout;

    public LoadingComponent() {
        super();
        setShowSuccess(true);
    }

    @Override
    protected final boolean onClickEvent() {
        if (!cancelable) {
            return false;
        }
        if (stateLayout != null)
            stateLayout.showSuccess();// 点击的时候显示成功状态
        return true;
    }

    /**
     * setCancelable
     * @param cancelable
     * @return
     */
    public LoadingComponent setCancelable(boolean cancelable) {
        this.cancelable = cancelable;
        return this;
    }

    public boolean isCancelable() {
        return cancelable;
    }

    public void setStateLayout(StateLayout layout) {
        stateLayout = layout;
    }
}
